class AdminwebsitearticlesController < ApplicationController
before_filter :authorize
    layout "adminwebsitearticles"
 uses_tiny_mce(:options => {:theme => 'advanced',
                           :browsers => %w{msie gecko},
                           :theme_advanced_toolbar_location => "top",
                           :theme_advanced_toolbar_align => "left",
                           :theme_advanced_resizing => true,
                           :theme_advanced_resize_horizontal => false,
                           :paste_auto_cleanup_on_paste => true,
                           :theme_advanced_buttons1 => %w{cut,copy,paste,pastetext,pasteword|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,image,media,anchor,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor},
                           :theme_advanced_buttons2 => [],
                           :theme_advanced_buttons3 => [], 
                           :editor_selector => "tiny_mce",                               	                    	
                           :theme_advanced_statusbar_location=>"bottom",
                           :plugins => %w{contextmenu paste preview media}},
              :content_css=> "css/content.css",
              :only => [:new, :edit, :show, :index])
                  
      active_scaffold :article do |config|
  config.label = "Articles"
#  config.action_links.add 'export_csv', :label => 'Export to Excel', :page => true
config.show.link.label = "Show Detail"  
config.show.link.type = :record
config.show.link.inline = true
  config.show.link.position = :after 
  
      config.list.sorting = { :published_at => :desc }
  
	  config.columns[:category].form_ui = :select  
    config.columns[:synopsis].form_ui = :textarea
    config.columns[:synopsis].options = {:rows => 60, :cols => 100}


    config.columns[:body].form_ui = :textarea
    config.columns[:body].options = {:rows => 60, :cols => 100}
    
    config.columns[:published].form_ui = :checkbox    
#    config.columns[:published].inplace_edit = true
	  config.columns = [:title,:synopsis,:body,:category,:created_by,:published,:published_at,:last_accessed_at,:last_accessed_user,:last_updated_at,:last_updated_user,:user_published_by]
    config.list.columns.exclude :synopsis,:body
    
		config.action_links.add 'mytest', :label => 'Websites', :type => :record, :page => true
		config.action_links.add 'mytest1', :label => 'Photos', :type => :record, :page => true
		config.action_links.add 'mytest2', :label => 'Tags', :type => :record, :page => true

    config.create.columns.exclude(:synopsis,:body,:created_by,:published_at,:last_accessed_at,:last_accessed_user,:last_updated_at,:last_updated_user)  
    config.create.columns.add_subgroup "Detail Information"  do |group|       
       	group.add(:synopsis,:body) 
       	end     
       	
    config.update.columns.exclude(:synopsis,:body,:created_by,:published_at,:last_accessed_at,:last_accessed_user,:last_updated_at,:last_updated_user)  
    config.update.columns.add_subgroup "Detail Information"  do |group|       
    	group.add(:synopsis,:body)  
    	end  

    config.show.columns.exclude(:title,:category,:created_by,:published,:published_at,:last_accessed_at,:last_accessed_user,:last_updated_at,:last_updated_user,:user_published_by)       	
  config.show.label = "Show Detail"
  end
  

  
  def mytest
  @all_websitesinfs = Websitesinf.find(:all)
    @article = Article.find(params[:id])
  end
  
    def mytest1
   redirect_to article_photos_path(:article_id => params[:id])
  end
  
      def mytest2
#   redirect_to :controller =>'article_tags',:action=>'remotetags',:article_id => params[:id]
   redirect_to article_tags_path(:article_id => params[:id])
  end
  
    def show
  super
 # redirect_to  :controller => 'index'
 # return
    @article = Article.find(params[:id])
    @article.last_accessed_user = User.find(session[:user_id]).name
    @article.last_accessed_at = Time.now
    @article.save
   #  redirect_to  :controller => 'websitesinfs',:action=>'show'
  end
   def before_create_save(record)

    record.user_published_by = params[:record][:user_published_by]
   
  end
  
      def update

  super
@mytest = params[:record][:user_published_by]
    @article = Article.find(params[:id])
     @article.user_published_by = @mytest 
    @article.last_updated_user = User.find(session[:user_id]).name
    @article.last_updated_at = Time.now
    @article.save

  end 
end
